@echo off
set RAR_EXE="C:\Program Files\WinRAR\WinRAR.exe"

:: dev、prod、test
set BUILD_TAG=prod
set DIST_PATH=dist

:: ZipName
for /f "tokens=2 delims==" %%i in (
    'wmic os get localdatetime /value ^| findstr "LocalDateTime"'
) do set "datetime=%%i"
set hour=%time:~0,2%
if "!hour:~0,1!"==" " set hour=0!hour:~1,1%
set output=%date:~5,2%%date:~8,2%%hour%%time:~3,2%
set ZIP_NAME=vis-admin-%BUILD_TAG%-%output%.zip

RD /S /Q  %DIST_PATH%
del /Q %ZIP_NAME%

call npm run build:%BUILD_TAG%

%RAR_EXE% a -ep1 %ZIP_NAME% %DIST_PATH%
RD /S /Q  %DIST_PATH%
call start .
exit